import routerConfig from './router/index';
import httpConfig from './http/index';
import {Notify, Dialog, Toast} from 'vant';

Toast.setDefaultOptions('loading', { duration: 0 });

Toast.allowMultiple(true);

export default function (options) {
    options
        .autoAddLoading(false)
        .components(require.context('./components', false, /\.vue/))
        .methods(require('./methods/index').default)
        .store()
        .http(config => httpConfig(config, options))
        .router(config => routerConfig(config, options))
        .mappings(config => config.pageQueryParam({pageNum: 'pageNumber', pageSize: 'pageSize'}))
        .tips(config => config
            .success(message => Toast({message, icon: 'success'}))
            .error(message => Notify({type: 'danger', message}))
            .warning(Toast)
            .confirm((message, title = '提醒') => Dialog.confirm({message, title}))
        )
        .build();
}
